package com.lc.afbx.activity;

import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.view.ViewGroup;

import com.lc.afbx.BaseApplication;
import com.lc.afbx.util.UtilPermission;
import com.zcx.helper.activity.AppPictureV4Activity;
import com.zcx.helper.bound.BoundViewHelper;
import com.zcx.helper.util.UtilSDCard;

/**
 * Created by Administrator on 2016/3/14.
 */
public abstract class BasePictureActivity extends AppPictureV4Activity {

    private static String[] PERMISSIONS_STORAGE = {
            Manifest.permission.READ_EXTERNAL_STORAGE,
            Manifest.permission.WRITE_EXTERNAL_STORAGE
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        // Check if we have write permission
        int permission = ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
        if (permission != PackageManager.PERMISSION_GRANTED) {
            // We don't have permission so prompt the user
            ActivityCompat.requestPermissions(
                    this,
                    PERMISSIONS_STORAGE,
                    1
            );
        }

        BaseApplication.INSTANCE.addActivity(this);

    }

    @Override
    public void setContentView(int layoutResID) {

        super.setContentView(layoutResID);

        BoundViewHelper.boundView(this, BaseApplication.ScaleScreenHelper.loadView((ViewGroup) getWindow().getDecorView()));

    }

    @Override
    protected void onDestroy() {

        super.onDestroy();

        BaseApplication.INSTANCE.finishActivity(this);

    }



    @Override
    protected String getCameraAbsolutePath() {

        return UtilSDCard.getSDCardPath() + "afbx/";

    }

}
